<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<fmt:setBundle basename="ApplicationResources" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><fmt:message key="title.maintainUser" /></title>

<script>
	$(function() {
		$( "#dob" ).datepicker({ dateFormat: "yy-mm-dd" });
	});
</script>
</head>
<h2>
		<fmt:message key="title.maintainUser" />
</h2>
<form action="${pageContext.request.contextPath}/controller/createUser" method=post>
<input type="hidden" name="insert" value="${insert}" />
		<center>
		<table class="framed">
		<tr>
		<td>
		<table cellpadding=4 cellspacing=2 border=0  >
		<tr align="left">
			<td valign=top >User Name<sup>*</sup><br> <input
				type="text" name="name" size=25 value="${name}" maxlength=25 ></td>
			<td valign=top> Date of Birth<sup>*</sup> <br>
			<input type="text" name="dob" id="dob" value="${dob}" >
			</td>
		</tr>
		
		<c:if test="${insert != 'false'}">
		<tr align="left">
			<td valign=top>Password<sup>*</sup> <br>
			<input type="password" name="password" size=10 value="" maxlength=10></td>
			<td valign=top>Confirm Password<sup>*</sup> <br>
			<input type="password" name="confirmpassword" size=10 value="" maxlength=10></td>
			<br>
		</tr>
		</c:if>
		
		<tr align="left">
			<td valign=top>Address Line 1<sup>*</sup> <br>
			<textarea rows="3" cols="25" name="addressLine1">${addressLine1}</textarea></td>
			<td valign=top>Address Line 2<sup></sup> <br>
			<textarea rows="3" cols="25"  name="addressLine2">${addressLine2}</textarea></td>
			<br>
		</tr>
		<tr align="left">
			<td valign=top>Zip Code<sup>*</sup> <br> <input
				type="text" name="zipcode" value="${zipcode}" size=5 maxlength=6></td>
			<td valign=top>City:<sup>*</sup> <br>
			<input type="text" name="city" size=20 value="${city}" maxlength=20></td>
		</tr>
		<tr align="left">
			<td valign=top>Country:<sup>*</sup> <br>
			<input type="text" name="country" size=20 value="${country}" maxlength=20></td>
			<td valign=top>State:<sup>*</sup> <br>
			<input type="text" name="state" size=20 value="${state}" maxlength=20></td>
		</tr>
		<tr align="left">
			<td>
			Roles <br>
			
			<select name="roles" multiple>
				<c:set var="contains" value="false" />
				<c:forEach var="item" items="${userRoles}">
				  <c:if test="${item.roleId == '1'}">
				    <c:set var="contains" value="true" />
				  </c:if>
				</c:forEach>
				<c:choose>
					<c:when test="${contains == true}">
					 	<option value="1" selected>Station Manager</option>
					</c:when>
					<c:otherwise>
					<option value="1">Station Manager</option>
					</c:otherwise>
				</c:choose>
				
				<c:set var="contains" value="false" />
				<c:forEach var="item" items="${userRoles}">
				  <c:if test="${item.roleId == '2'}">
				    <c:set var="contains" value="true" />
				  </c:if>
				</c:forEach>
				<c:choose>
					<c:when test="${contains == true}">
					 	  <option value="2" selected>Program Presenter</option>
					</c:when>
					<c:otherwise>
					<option value="2">Program Presenter</option>
					</c:otherwise>
				</c:choose>
				
				<c:set var="contains" value="false" />
				<c:forEach var="item" items="${userRoles}">
				  <c:if test="${item.roleId == '3'}">
				    <c:set var="contains" value="true" />
				  </c:if>
				</c:forEach>
				<c:choose>
					<c:when test="${contains == true}">
					 	<option value="3" selected>Program Producer</option>
					</c:when>
					<c:otherwise>
					<option value="3">Program Producer</option>
					</c:otherwise>
				</c:choose>
				
				<c:set var="contains" value="false" />
				<c:forEach var="item" items="${userRoles}">
				  <c:if test="${item.roleId == '4'}">
				    <c:set var="contains" value="true" />
				  </c:if>
				</c:forEach>
				<c:choose>
					<c:when test="${contains == true}">
					 	<option value="4" selected>System Administrator</option>
					</c:when>
					<c:otherwise>
					<option value="4">System Administrator</option>
					</c:otherwise>
				</c:choose>
				
				
				
				
			
   			</select>
			</td>
			<td valign=top>Brief Employment History <br>
			<textarea rows="3" cols="25" name="employment_history">${employment_history}</textarea></td>
	
		</tr>
		<tr bgcolor="">
			<td align=center colspan=2>
			<c:choose>
			<c:when test="${not empty errorMessage}">
								<p class="bodysmallred">${errorMessage}</p>
							</c:when>
			</c:choose>
			 <input type="submit" value="Submit"></td>
		</tr>
	</table>
	</td>
	</tr>
	</table>
		</center>

</form>
</body>
</html>